<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <pe:importEnum type="vn.vfriends.soffice.model.RoleCode" var="RoleCode" allSuffix="ALL_ROLE_VALUES" />
    <f:view contentType="text/html">    
        <h:head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title><ui:insert name="title">sOffice</ui:insert></title>
        </h:head>
        <h:body>
            <h:outputStylesheet library="css" name="default.css"/>
            <h:outputStylesheet library="css" name="component.css"/>
            
            <pe:ajaxErrorHandler widgetVar="ajaxErrorHandler" button="Hide" buttonOnclick="ajaxErrorHandler.hide();" />  
            <pe:ajaxErrorHandler type="javax.faces.application.ViewExpiredException" button="Reload"  
                     buttonOnclick="document.location.href=document.location.href;"  
                     body="Due to inactivity on page please push RELOAD to continue." title="Page expired ..."/>
            
            <ui:insert name="idleMonitor">
                <h:form id="monitorForm" prependId="false">
                    <p:idleMonitor timeout="#{session.maxInactiveInterval * 1000}" onidle="idleDialog.show();" 
                                   onactive='window.location = "#{request.contextPath}/index.jsf";'/>

                    <p:dialog header="Info" resizable="false" widgetVar="idleDialog" modal="true" width="400">
                        <h:outputText value="Phiên làm việc đã hết hạn" />
                    </p:dialog>
                </h:form>
            </ui:insert>
            
            <ui:insert name="dialog"></ui:insert>
            
            <p:layout fullPage="true">
                <p:layoutUnit position="north" closable="false" resizable="false" size="50">
                    <h:form id="headerForm" prependId="false">
                        <h:panelGrid columns="2" width="100%">
                            <h:panelGroup style="display: inline; float: left; padding: 5px;">
                                <h:outputText value="sOffice" style="font-size: 14px; font-weight: bold;"/>
                            </h:panelGroup>
                            <h:panelGroup style="display: inline; float: right; padding-right: 5px;">
                                <h:outputText value="#{request.remoteUser}" style="padding-left: 10px;" 
                                              rendered="#{not empty request.remoteUser}"/>
                                
                                <p:commandLink id="logout" actionListener="#{securityBean.logoutAction()}" value="Logout" style="padding-left: 10px;"
                                               update="@(.ui-panel)" rendered="#{not empty request.remoteUser}"/>
                                <p:commandLink id="login" action="login" ajax="false" value="Login" style="padding-left: 10px;" 
                                               rendered="#{empty request.remoteUser}"/>
                            </h:panelGroup>
                        </h:panelGrid>
                    </h:form>
                </p:layoutUnit>
                
                <p:layoutUnit position="center" closable="true" collapsible="true">
                    <h:form id="statusForm" prependId="false">
                        <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  

                        <p:dialog modal="false" widgetVar="statusDialog" header="Status"   
                                  draggable="false" closable="false">  
                            <p:graphicImage value="#{resource['images:ajaxloadingbar.gif']}" />  
                        </p:dialog>
                    </h:form>
                    <ui:insert name="content"></ui:insert>
                </p:layoutUnit>
            </p:layout>
        </h:body>
    </f:view>    
</html>
